home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / language / prlogtxt.arc / README.DOC < prev   
Text File  |  1988-07-24  |  8KB  |  181 lines

  1.  
  2.                  TOY Prolog ST - English edition
  3.                  -------------------------------
  4.  
  5. Contents of disk
  6. ----------------
  7.      TOY.PRG      )      The TOY Prolog interpreter
  8.      SYSFILE.TOY  )
  9.  
  10.      PROLOG.DOC          53-page manual, translated from German
  11.  
  12.      README.DOC          The file you are reading
  13.  
  14.      BOOTER.TOY   )      Auxiliary programs in
  15.      EDITOR.TOY   )        intermediate code - see
  16.      CALLTREE.TOY )        section 4 of manual
  17.  
  18.      TICTAC.TOY          Noughts & crosses demo (intermediate 
  19.                            code) (manual, p.42)
  20.  
  21.   \SOURCE\ folder: programs in Prolog (in English originally):
  22.  
  23.      MONITOR.PRO         Source code for user interface (p.47)
  24.  
  25.      EDITOR       )      Source code for auxiliary programs
  26.      CALLTREE     )        (pp.38-39)
  27.  
  28.      ALPHA        )
  29.      TOYSEQ       )      Demonstration programs (pp.40-42)
  30.      TICTAC.TOE   )
  31.  
  32.   \DEMOS\ folder: more Prolog programs (translated from German):
  33.  
  34.      TOYDEMOS            graphics demo, access to disk directory,
  35.                            + a simple recursive tab function
  36.      FAMILY              logic of family relationships
  37.      COLOURS             colouring a map with 4 colours
  38.      QUIKSORT            sorting lists
  39.  
  40. Introduction
  41. ------------
  42. Welcome to Prolog - PROgramming in LOGic - the 'fifth generation' 
  43. language  currently replacing LISP as the language of choice  for 
  44. artificial intelligence programming. A few lines of Prolog can do 
  45. things  that would take pages of code in a conventional  language 
  46. like  Pascal,  C or BASIC.  But as it is fundamentally  different 
  47. from  sequential/algorithmic languages like these (and also  from 
  48. other,  less conventional computer languages),  you have a  whole 
  49. set of new concepts to learn before you can make much use of  its 
  50. power. It is not just the jargon that's weird and unfamiliar, but 
  51. the  whole  philosophy  of programming  that  Prolog  terminology 
  52. describes.
  53.  
  54.      Let's face it, it takes a book to explain what Prolog is all 
  55. about. The manual describes this particular implementation pretty 
  56. thoroughly,  but it does not set out to be an introductory text - 
  57. it  assumes  you  already  know  what  words  like  'arity'   and 
  58. 'principal functor' mean.  So if you do want to learn Prolog  you 
  59. will have to get a book about it. The standard text is the one by 
  60. Clocksin  &  Mellish,  mentioned  in  the  manual.  A  short  and 
  61. comparatively cheap book that I am finding quite helpful,  though 
  62. it  does  not  cover  everything  in  TOY  Prolog,  is  J.Doores, 
  63. A.R.Reiblein & S.Vadera: Prolog - Programming for Tomorrow. Sigma 
  64. Press, Wilmslow, Cheshire, 1987. £10-95. 
  65.  
  66.      If you do not have a textbook to refer to yet,  just in case 
  67. reading the manual still leaves you wondering where to start, the 
  68. following notes may help you get going with this package.
  69.  
  70. Using TOY Prolog
  71. ----------------
  72. Run  TOY.PRG from the desktop,  with SYSFILE.TOY present  on  the 
  73. same  directory.  You should eventually get a message saying  the 
  74. program is listening and a prompt,
  75.      ?-
  76. followed  by a blinking cursor.  Now you are supposed to enter  a 
  77. valid Prolog clause,  terminated by a full stop. This sets Prolog 
  78. a goal, which it will attempt to satisfy. In some cases, a lot of 
  79. printout  can be generated on the way,  but eventually  the  goal 
  80. will  either succeed or fail,  and Prolog will respond  'yes'  or 
  81. 'no' respectively, and give you another '?-' prompt.
  82.  
  83.      E.g.  you can set Prolog problems in simple arithmetic  such 
  84. as
  85.      ?- sum(27,34,X).
  86. or
  87.      ?- sum(X,3,-11).
  88. Here  X,  being a sequence of alphanumeric  characters  beginning 
  89. with a capital letter,  is interpreted as a variable,  and Prolog 
  90. will give it a value.  To get a new prompt,  type a full stop and
  91. Return. Or you can ask
  92.      ?- 32*48 > 1024/3.
  93. or
  94.      ?- 'neil' @< 'margaret'.
  95. and just get 'yes' or 'no'.
  96.  
  97. To quit TOY Prolog, just type
  98.         stop.
  99.  
  100. Loading a program
  101. -----------------
  102. In principle,  you can enter complicated predicates directly like 
  103. this, but it is not very convenient. For one thing, if you make a 
  104. mistake  you have to type the whole line again.  It is  generally 
  105. easier to create a Prolog program outside the interpreter,  using 
  106. your favourite programming editor,  and load it in from disk when 
  107. Prolog  is running.  Once loaded,  it can be modified  using  the 
  108. editor provided.
  109.  
  110.      There are two ways of loading programs.  A program in Prolog 
  111. source code is loaded with 'consult'.  E.g.  to load the  example 
  112. program FAMILY from drive B you enter
  113.      ?- consult('b:\demos\family').
  114. whereupon Prolog will read it in,  echoing it all to the  screen, 
  115. stopping to execute commands (beginning with ':-') when it  comes 
  116. to them, until it comes to the 'end.'. At that point the goal has 
  117. been satisfied, so Prolog prints 'yes' and returns control to the 
  118. keyboard.
  119.  
  120.      This is very slow,  so another method is also provided. Once 
  121. your  program  is  fully debugged,  you  can  translate  it  into 
  122. intermediate code as described in the manual, generating a '.TOY' 
  123. file,  which can then be loaded very quickly with 'sysload'. E.g. 
  124. to load the editor you enter
  125.      ?- sysload('b:\editor.toy').
  126.  
  127.      Once a program has been loaded,  the information it contains 
  128. remains in Prolog's built-in database. You can call predicates in 
  129. it, and ask questions using the facts and rules it contains. E.g. 
  130. after loading FAMILY, you can enter
  131.      ?- parent(X, jesus).
  132. and Prolog will answer
  133.      X is joseph
  134. leaving the cursor on the same line. If you type a semicolon (and 
  135. Return), it will resatisfy this goal with another solution,
  136.      X is mary
  137. This time,  attempting to resatisfy the goal fails,  there are no 
  138. more solutions.
  139.  
  140. There is plenty of study material in the example programs, and it 
  141. is worth printing listings of them as well as of the manual.
  142.  
  143. This translation
  144. ----------------
  145. TOY  Prolog  was written in Warsaw and published in  an  English-
  146. language  book,  which  unfortunately  I have not  been  able  to 
  147. obtain. This Atari ST version was created in Germany and released 
  148. as  a  public  domain package  with  German  documentation.  This 
  149. English  version  of the package is the same except that  I  have 
  150. translated  the documentation into English and edited it  into  a 
  151. single  document,  adding  a  fuller table of  contents  and  two 
  152. indexes  (one  of  the GEM functions by  their  standard  names); 
  153. translated the comments in the example programs;  and added  this 
  154. README file. One or two little mistakes I happened to spot in the 
  155. German documentation have been corrected,  but I cannot guarantee 
  156. the rest is perfect!  Once upon a time,  the German documentation 
  157. appears  to have been in FirstWord format,  with some  names  and 
  158. symbols distinguished by bold type. By the time it reached me, it 
  159. was  in ASCII and this distinction had been lost - sorry if  this 
  160. adds any confusion.  Being a beginner in Prolog, not particularly
  161. familiar  with German,  and without access to the original source 
  162. book,  I can hardly have avoided an occasional slip or  deviation 
  163. from  the  norms  of TOY Prolog  terminology,  however  it  seems 
  164. preferable to release the translation in its present form  rather 
  165. than  sitting on it just because I might be able to do it  better 
  166. with another year's experience.
  167.  
  168.      Though  my contribution is small compared with that  of  the 
  169. professionals who wrote the program,  still translating over 100k 
  170. of  files as technical as this is by no means a negligible  task, 
  171. in  fact it amounted to several weeks' work all told.  And  while 
  172. they were no doubt paid for their work,  I don't get a penny  for 
  173. mine.  So if you would like to encourage me to help make more  of 
  174. the  excellent PD software that comes from Germany  available  in 
  175. English via the ST Club, why not send me a donation?
  176.  
  177.                                    Martin Willson,
  178.                                      1 Bincleaves Road,
  179.                                        Wey